#include "button.hpp"
#include "control.hpp"
#include <allegro.h>
#include <string>

void cButton::draw(BITMAP * &bufor)
{
    if (!show || deleted) return;

    masked_stretch_blit(img, bufor, 0, 0, img->w, img->h, pos->x, pos->y, size->x, size->y);
    textprintf_centre_ex(bufor, font, pos->x + size->x / 2, pos->y + size->y / 2, textColor, -1, "%s", value.c_str());
}

cButton::cButton(int x, int y, int w, int h, char * v, int tCol, int bgCol) : cControl(x, y, w, h, v, tCol, bgCol)
{
    img = load_bmp("GFX\\gui\\button.bmp", default_palette);
}

cButton::~cButton()
{
    destroy_bitmap(img);
}
